Skip to content

fix: Handle HTTP errors gracefully in wait-for-image action#88

Open
janisz wants to merge 1 commit intomainfrom
fix-wait-for-image-http-errors
Open

fix: Handle HTTP errors gracefully in wait-for-image action#88
janisz wants to merge 1 commit intomainfrom
fix-wait-for-image-http-errors

Conversation

@janisz
Copy link

@janisz janisz commented Mar 12, 2026

The action now catches and logs HTTP errors (502, 404, etc.) and network errors instead of crashing, allowing the polling loop to continue until the image appears or timeout is reached.

https://github.com/stackrox/collector/actions/runs/23010218381/job/66818670130?pr=3021

Run "${GITHUB_ACTION_PATH}/wait-for-images.py" \
Will check the following image(s):
rhacs-eng/release-collector:3.24.0-84-ge4063a5f45-fast
Waiting 30 more second(s)...
			⋮
Waiting 30 more second(s)...
Traceback (most recent call last):
  File "/home/runner/work/_actions/stackrox/actions/v1/release/wait-for-image/wait-for-images.py", line 105, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/runner/work/_actions/stackrox/actions/v1/release/wait-for-image/wait-for-images.py", line 14, in main
    res = check_images(args)
          ^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/_actions/stackrox/actions/v1/release/wait-for-image/wait-for-images.py", line 70, in check_images
    found[i] = check_image(images[i], args.quay_token)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/_actions/stackrox/actions/v1/release/wait-for-image/wait-for-images.py", line 97, in check_image
    with urllib.request.urlopen(req) as resp:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 215, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 521, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 630, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 559, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 492, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 639, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 502: Bad Gateway
Error: Process completed with exit code 1.

The action now catches and logs HTTP errors (502, 404, etc.) and network
errors instead of crashing, allowing the polling loop to continue until
the image appears or timeout is reached.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@janisz janisz requested a review from a team as a code owner March 12, 2026 16:33
@msugakov
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants